class WelcomeController < ApplicationController
  def index
    categories = Category.all.to_a

    hotel_cat = categories.detect{|i| i.name == "酒店" }
    video_cat = categories.detect{|i| i.name == "视频" }
    new_cat = categories.detect{|i| i.name == "咨询" }
    doing_cat = categories.detect{|i| i.name == "去干吗" }
    where_cat = categories.detect{|i| i.name == "去哪里" }

    @hotel_img = hotel_cat.cover.present? ? hotel_cat.cover : 'hotel.png'
    @video_img = video_cat.cover.present? ? video_cat.cover : 'video.png'
    @new_img = new_cat.cover.present? ? new_cat.cover : 'news.png'
    @what_img = doing_cat.cover.present? ? doing_cat.cover : 'what.png'
    @where_img = where_cat.cover.present? ? where_cat.cover : 'where.png'

    @where_tags = where_cat.tags.split(',')
    @doing_tags = doing_cat.tags.split(',')
    @hotes_tags = hotel_cat.tags.split(',')
    @news_tags = new_cat.tags.split(',')
    @videos_tags = video_cat.tags.split(',')
  end

  def about
    @about = Footer.where(name: params[:tab]).first
  end
end